package com.linkme2night.model;
 

import org.w3c.dom.*;

public class ClubberDAO {

     private Document doc;
     private NodeList nameList; 
     private NodeList cidList;
     private NodeList nodeList;

     	//Constructor 
    	public ClubberDAO(){
    		XmlCon XmlCon = new XmlCon();
            XmlCon.LoadFile();
            doc = XmlCon.getDoc();
            nodeList = doc.getElementsByTagName("Clubber");
            nameList = null; 
    
    	}
    	
    	//Get clubberName based on Id
        public String getName(int clubberId) {

            for (int i = 0; i < nodeList.getLength(); i++) {
 
                Node node = nodeList.item(i);


                Element fstElmnt = (Element) node;
                cidList = fstElmnt.getElementsByTagName("ClubberId");
                Element cidElement = (Element) cidList.item(0);
                cidList = cidElement.getChildNodes();
                
                System.out.println("" + cidList.item(0).getNodeValue());
                if(cidList.item(0).getNodeValue().equals(""+clubberId))
                {
                nameList = fstElmnt.getElementsByTagName("Name");
                Element nameElement = (Element) nameList.item(0);
                nameList = nameElement.getChildNodes();

            }
            
        }
        return (""
                        + ((Node) nameList.item(0)).getNodeValue());
    }
        }

        
